//#pragma once
#ifndef __FUNC_TIME__
#define __FUNC_TIME__

#include <map>
#include <stdint.h>
#include "HLS.h"
using namespace std;

enum func_type {isPrecedence_t = 1, isResourceAvailable_t = 2, occupyResource_t = 3, releaseResource_t = 4, calculateMaxScheduleTime_t = 5, levelbound_t = 6, lowbound_t = 7, updateALAP_t = 8, cpbound_t = 9, updateasap_t = 10 };

class FuncTimer
{
public:
  FuncTimer ( void );
  ~FuncTimer ( void );

  static map<func_type, uint64_t> tickets;
  static map<func_type, uint64_t> times;
  static uint64_t total_tickets;
  static uint64_t temp_tickets;

  static void init()
  {
    for ( int i = 1; i <= 10; i++ )
      {
        tickets[ ( func_type ) i] = 0;
        times[ ( func_type ) i] = 0;
      }

    temp_tickets = 0;
    total_tickets = 0;
  };

  static void checkin ( enum func_type type )
  {
    FuncTimer::temp_tickets = GetCycleCount();

  };

  static void checkout ( enum  func_type type )
  {
    FuncTimer::tickets[type] += GetCycleCount() - FuncTimer::temp_tickets;
    FuncTimer::times[type]++;
  };
};

#endif
